<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$("#input_autocomplete_airline")
								.tokenInputFixed(
										"${pageContext.request.contextPath}/json/airlinejson.html",
										{
											theme : "yolo",
											preventDuplicates : true,
											onDelete: function (item) {
												$("#token-input-input_autocomplete_airline").css({"display":"block"});
												$( "#token-input-input_autocomplete_airline" ).focus();
								            },
										// add here code and name
									    	resultsFormatter : function(item) {
									    			return "<li>" + item.id + " - " + item.name + "</li>";
									    	},
									    	tokenFormatter : function(item) {
									    			return "<li>" + item.id + " - " + item.name + "</li>";
									    	}
								    	});

						var airlineStr = "${params.airlines}";

						if(airlineStr===""){  //for task
							airlineStr = "${parameters.airlines}";
						}

						if (!(airlineStr === "")) {
							var arr = airlineStr.split(";");
							for (var i = 0; i < arr.length; i++) {
								var airline = arr[i].split("-");
								$("#input_autocomplete_airline").tokenInputFixed("add", {
									id_ : 0,
									id : airline[0],
									name : airline[1]
								});
							}
						}
												
						if($('#input_autocomplete_airline').val()!=""){
				    		$("#token-input-input_autocomplete_airline").css({"display":"none"});
				    	}
						$('.token-input-list-yolo').focusout(function(){
							if($('ul.token-input-list-yolo').text().length > 1){
								$("#token-input-input_autocomplete_airline").css({"display":"none"});
							}
						});

						$('#input_autocomplete_airline').focusout(function(){
							if($('ul.token-input-list-yolo').text().length > 1){
								$("#token-input-input_autocomplete_airline").css({"display":"none"});
							}
						});

						$('.token-input-list-yolo').click(function(){
							$("#token-input-input_autocomplete_airline").css({"display":"block"});
							$( "#token-input-input_autocomplete_airline" ).focus();
						});

						$('#input_autocomplete_airline').focus(function(){
							$("#token-input-input_autocomplete_airline").css({"display":"block"});
							$( "#token-input-input_autocomplete_airline" ).focus();
						});
					});
</script>
